package mapred.config;

import java.util.HashMap;
import java.util.Map;

public class AppConfig implements IConfig {

    private Map<String, String> map = new HashMap<String, String>();

    private int args = 0;

    public void set(String key, Object value) {
        this.map.put(normalizeKey(key), value.toString());
    }

    public String get(String key) {
        return map.get(normalizeKey(key));
    }

    public boolean containsKey(String key) {
        return this.map.containsKey(normalizeKey(key));
    }

    public String normalizeKey(String key) {
        if (key == null) {
            String ret = "args[" + args + "]";
            args++;
            return ret;
        } else {
            return key.toLowerCase();
        }
    }

    public String toString() {
        return this.map.toString();
    }

    public void remove(String key) {
        this.map.remove(normalizeKey(key));
    }

}
